package com.example.core.queue;

import com.example.core.queue.distuptor.config.QueueRingBuffer;
import com.example.core.queue.distuptor.event.QueueEvent;
import com.example.core.queue.distuptor.handler.QueueWorkerEventHandler;
import com.example.core.queue.distuptor.producer.QueueProducer;

public class Test {


    public static void main(String[] args) {

        QueueRingBuffer queueRingBuffer=new QueueRingBuffer(TestQueueEvent::new);
        queueRingBuffer.setConsumerListener(new QueueWorkerEventHandler() {
            @Override
            public void onEvent(QueueEvent event) throws Exception {
                TestQueueEvent ev=(TestQueueEvent)event;
                System.out.println("event:"+ev.getName());
            }
        });
        queueRingBuffer.start();

        for(int i=1;true;i++){
            QueueProducer producer = new QueueProducer();
            TestQueueEvent event=new TestQueueEvent();
            event.setName("event_"+i);
            producer.sendData(event);
        }
    }



}
